package fr.utbm.gi.vi51.slizers.pw.gui.menu;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JPanel;

import fr.utbm.gi.vi51.slizers.pw.gui.LaunchSimulationListener;

/**
 * @author Adrien
 * 
 * Implementation of a GUI Panel displaying the menu
 *
 */

public class MenuPanel extends JPanel implements creaturesSelectionListener
{

	/**
	 * Version number associated to the serializable class.
	 */
	private static final long 			serialVersionUID = 3289675630316162323L;
	
	/**
	 * The panel allowing to select the map to use
	 */
	private final MapSelectorPanel 		mapSelectorPanel;
	
	/**
	 * The panel allowing to select some creatures
	 */
	private final CreatureSelectorPanel creatureSelectorPanel;
	
	/**
	 * The panel containing the buttons relative to the menu
	 */
	private final MenuButtonPanel		menuButtonPanel;
	
	
	/**
	 * Constructor
	 */
	public MenuPanel( LaunchSimulationListener _gui )
	{
		this.mapSelectorPanel		= new MapSelectorPanel();
		this.menuButtonPanel		= new MenuButtonPanel( _gui );
		this.creatureSelectorPanel	= new CreatureSelectorPanel( this );

		this.setLayout( new BorderLayout() );

		// Add the menu elements
		this.add( this.mapSelectorPanel, BorderLayout.WEST );
		this.add( this.creatureSelectorPanel, BorderLayout.EAST );
		this.add( this.menuButtonPanel, BorderLayout.SOUTH );
		
		setPreferredSize( new Dimension(1100, 600) );
		setMinimumSize( new Dimension(1100, 600) );
	}
	
	/**
	 * Returns the selected map path.
	 * 
	 * @return the selected map path
	 */
	public String getSelectedMapPath()
	{
		return this.mapSelectorPanel.getSelectedMapPath();
	}
	
	/**
	 * Returns the selected creatures
	 * 
	 * @return the selected creatures
	 */
	public String getSelectedCreaturesPath()
	{
		return this.creatureSelectorPanel.getSelectedCreaturesPath();
	}

	/* (non-Javadoc)
	 * @see fr.utbm.gi.vi51.slizers.pw.gui.menu.creaturesSelectionListener#creatureSelectionChanged(boolean)
	 */
	@Override
	public void creatureSelectionChanged( boolean _isSelected )
	{
		this.menuButtonPanel.setCBState( _isSelected );
		
	}
	
	/**
	 * Returns the number of creatures set by the user
	 * 
	 * @return the number of creatures set by the user
	 */
	public int getCreaturesNumber()
	{
		return this.menuButtonPanel.getCreaturesNumber();
	}
}
